﻿Imports System.Data.OleDb
Imports System.IO

Public Class Employee

    Private Sub Employee_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim databaseProvider As DatabaseProvider = databaseProvider.Instance()
        EmployeeDataGrid.DataSource = databaseProvider.GetAllEmployees()
        StaffMembersToolStripMenuItem1.Enabled = False

    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        Application.Exit()
    End Sub

    Private Sub BtnDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDel.Click
        If MsgBox("Are You Sure?", MsgBoxStyle.YesNo, Title:="Confirm") = vbYes Then

        End If
    End Sub
    Private Sub AdminToolsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Start.Show()
        Me.Close()
    End Sub

    Private Sub SalesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SalesToolStripMenuItem1.Click
        Sales.Show()
        Me.Close()
    End Sub

    Private Sub OrdersToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OrdersToolStripMenuItem1.Click
        Orders.Show()
        Me.Close()
    End Sub

    Private Sub ProductsToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductsToolStripMenuItem1.Click
        Product.Show()
        Me.Close()
    End Sub

    Private Sub ChooseLanguageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChooseLanguageToolStripMenuItem.Click
        Language.Show()
        Me.Close()
    End Sub

    Private Sub HelpToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HelpToolStripMenuItem1.Click
        Help.Show()
    End Sub

    Private Sub CustomersToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CustomersToolStripMenuItem1.Click
        Customer.Show()
        Me.Close()
    End Sub

    Private Sub BtnAddNew_Click(sender As System.Object, e As System.EventArgs) Handles BtnAddNew.Click
        NewEmployee.Show()
    End Sub

    Private Sub TxtName_TextChanged(sender As System.Object, e As System.EventArgs) Handles TxtName.TextChanged
        EmployeeDataGrid.DataSource = employeeSearch()
    End Sub

    Private Sub TxtSurname_TextChanged(sender As System.Object, e As System.EventArgs) Handles TxtSurname.TextChanged
        EmployeeDataGrid.DataSource = employeeSearch()
    End Sub

    Private Sub TxtTown_TextChanged(sender As System.Object, e As System.EventArgs) Handles TxtTown.TextChanged
        EmployeeDataGrid.DataSource = employeeSearch()
    End Sub

    Private Sub TxtPostcode_TextChanged(sender As System.Object, e As System.EventArgs) Handles TxtPostcode.TextChanged
        EmployeeDataGrid.DataSource = employeeSearch()
    End Sub

    Private Sub TxtPosition_TextChanged(sender As System.Object, e As System.EventArgs) Handles TxtPosition.TextChanged
        EmployeeDataGrid.DataSource = employeeSearch()
    End Sub

    Private Function employeeSearch() As BindingSource
        Dim databaseProvider As DatabaseProvider = databaseProvider.Instance()
        Return databaseProvider.FindEmployees(TxtName.Text, TxtSurname.Text, TxtTown.Text, TxtPostcode.Text, TxtPosition.Text)
    End Function

    Private Sub AdminToolsToolStripMenuItem_Click_1(sender As System.Object, e As System.EventArgs) Handles AdminToolsToolStripMenuItem.Click
        Start.Show()
        Me.Close()
    End Sub
End Class